package edu.zzuli.common;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import edu.zzuli.model.orm.po.GG_CZYB;
import edu.zzuli.model.orm.po.GG_JGBH;

public class MyVisit extends Visit implements Serializable {

	private static final long serialVersionUID = -979129454582624097L;

	public final static String USER_GG_CZYB = "GG_CZYB";

	public final static String DW_GG_JGBH = "DW_GG_JGBH";

	// public final static String BM_GG_JGBH = "BM_GG_JGBH";

	public final static String LOGIN_TIME = "LOGIN_TIME";

	public final static String USER_GG_BMXX = "SR_GG_BMXX";

	public final static String USER_GG_CZYLB = "USER_GG_CZYLB";

	public final static String Session_Map = "Session_Map";

	private Map loginInfoMap;

	public MyVisit() {
		this.loginInfoMap = new HashMap();
		this.loginInfoMap.put(Session_Map, new HashMap());
	}

	public Map getLoginInfoMap() {
		return loginInfoMap;
	}

	public void setLoginInfoMap(Map loginInfoMap) {
		this.loginInfoMap = loginInfoMap;
	}

	public GG_CZYB getCzy() {
		return (GG_CZYB) this.getLoginInfoMap().get(USER_GG_CZYB);
	}

	/**
	 * 获取所在单位信息
	 * 
	 * @return
	 */
	public GG_JGBH getGG_JGBH() {
		return (GG_JGBH) this.getLoginInfoMap().get(DW_GG_JGBH);
	}

	public String getLoginSj() {
		return (String) this.getLoginInfoMap().get(LOGIN_TIME);
	}

	public List<Map<String, String>> getListGG_CZYBMap() {
		return (List<Map<String, String>>) this.getLoginInfoMap().get(
				USER_GG_CZYLB);
	}

	public boolean isLogin() {
		return this.getLoginInfoMap() != null
				&& this.getLoginInfoMap().size() > 1;
	}

	// public void loginOut() {
	// // ACEGI_SECURITY_CONTEXT_KEY "ACEGI_SECURITY_CONTEXT"
	// SecurityContextHolder.clearContext();
	// this.loginInfoMap = null;
	// }
	
	/**
	 * 获取登录人员所属的第一个部门
	 * 
	 * @return
	 */
	public Map<String, String> getBMXX_First() {
		List<Map<String, String>> listBMXX = (List<Map<String, String>>) this.loginInfoMap
				.get(USER_GG_BMXX);
		if (listBMXX != null && listBMXX.size() > 0) {
			return listBMXX.get(0);
		} else {
			return null;
		}

	}

	/**
	 * 获取登录人员所属的部门列表
	 * 
	 * @return
	 */
	public List<Map<String, String>> getBMXX_List() {
		return (List<Map<String, String>>) this.loginInfoMap.get(USER_GG_BMXX);
	}

	@Deprecated
	public GG_JGBH getDW() {
		return this.getGG_JGBH();
	}

	public Map getSession() {
		return (Map) this.loginInfoMap.get(Session_Map);
	}
}